package com.xiweicheng;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.*;

@SpringBootApplication
@RestController
public class DockerLinkWebMysqlApplication {

	@Autowired
	TestRepository testRepository;

	@GetMapping("/")
	public Object home() {
		return "welcome!";
	}

	@GetMapping("/test/{id}")
	public Object getTest(@PathVariable("id") Long id) {
		return testRepository.findOne(id);
	}

	@PostMapping("/test")
	public Object SaveTest(@RequestBody Test test) {
		return testRepository.saveAndFlush(test);
	}

	public static void main(String[] args) {
		SpringApplication.run(DockerLinkWebMysqlApplication.class, args);
	}
}
